#include "Control.h"

Control::Control(NodeContainer* parent, bool isOutput) : Node(parent), isOutput(isOutput)
{
  if (isOutput) {
    addSource();
  } else {
    addSink();
  }
}

void Control::process(llvm::IRBuilder<> *builder) {
  if (isOutput) {
    sources[0]->setValue(builder->CreateLoad(val, "ctltmp"));
  } else {
    builder->CreateStore(terminals[0]->getValue(), val);
  }
}

void Control::setValue(llvm::Value *value) {
  val = value;
}
